import java.io.*;
import java.net.*;


public class Network implements Serializable{
	String hostname;
	int port;
	
	Socket socket = null;
	ObjectOutputStream out = null;
	ObjectInputStream in = null;
	
	public Network(String hostname, int port) {
		this.hostname = hostname;
		this.port = port;
	}
	
	public void setConnect(Socket socket, ObjectOutputStream out, ObjectInputStream in){
		this.socket = socket;
		this.out = out;
		this.in = in;
	}
	
	public void start() {
		try {
    			socket = new Socket(hostname, port);
			out = new ObjectOutputStream(socket.getOutputStream());
			in = new ObjectInputStream(socket.getInputStream());
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.exit(-1);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.exit(-1);
		}
	}
	
	public String getClientHost()
	{
		return hostname;
	}
	
	public int getClientPort()
	{
		return port;
	}
	
	public Socket getSocket(){
		return this.socket;
	}
	
	public ObjectOutputStream getOut(){
		return this.out;
	}
	
	public ObjectInputStream getIn(){
		return this.in;
	}
	
	public void close() {
		try {
			out.close();
			in.close();
			socket.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.exit(-1);
		}		
	}
}